package www.wen.com.common.lib.util

import android.content.Context
import android.content.pm.PackageManager
import android.content.pm.PackageManager.GET_UNINSTALLED_PACKAGES
import android.text.TextUtils
import com.orhanobut.logger.Logger
import www.wen.com.common.lib.app.BaseApplication.Companion.CONTEXT


/**
 * @author WEN
 * @Description:
 * @date 2020/12/30 10:47
 */
class CheckApkExist {

    companion object {

        const val FACE_BOOK = "com.facebook.katana"

        const val TWITTER = "com.twitter.android"

        @JvmStatic
        fun checkApkExist(packageName: String, context: Context = CONTEXT): Boolean {
            return if (TextUtils.isEmpty(packageName))
                false
            else
                try {
                    val info = context.packageManager
                            .getApplicationInfo(packageName,
                                    GET_UNINSTALLED_PACKAGES)
                    Logger.i("包名:$info")
                    true
                } catch (e: PackageManager.NameNotFoundException) {
                    false
                }
        }

    }

}